﻿@import "colors";

.transition(@timeout, @prop) {
    -moz-transition: @timeout @prop;
    -o-transition: @timeout @prop;
    -webkit-transition: @timeout @prop;
    transition: @timeout @prop;
}

.border-box() {
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.content-box {
    -moz-box-sizing: content-box;
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
}

.text-ellipsis() {
    -ms-text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    overflow: hidden;
    -ms-word-break: keep-all;
    word-break: keep-all;
    -ms-word-wrap: initial;
    word-wrap: initial;
}

.tinyselect-container {
    background-color: @con-bg;
    border: 1px solid @con-bd;
    height: auto;
    color: @con-color;
    z-index: 99;
    outline: none;
    .border-box();

    &:not(.tinyselect-mode-list) {
        position: absolute;
        border-top-width: 0;
        box-shadow: @con-sd 0 2px 4px 2px;
        
        &:hover {
            box-shadow: darken(@con-sd, 15%) 0 2px 4px 2px;
        }
    }

    &.tinyselect-mode-list {
        height: 100%;
    }

    &.tinyselect-mode-dropdown {
        display: none;
        // .content-box();
    }

    .tinyselect-box {
        overflow-y: auto;

        .tinyselect-item {
            .border-box();
            cursor: default;
            .text-ellipsis();
            border: 1px solid transparent;
            border-top-color: @item-bd;
            .transition(382ms, border-color);
            .transition(382ms, background-color);
            position: relative;
            padding: 0 5px;
            background-color: @item-bg;

            &-before {
                float: left;
            }

            &-text {
                float: left;
            }

            &-after {
                float: right;
            }

            &-hover {
                border-color: @item-hover-bd;
            }

            &-selected {
                // color: @item-selected-fg;
                .tinyselect-item-after {
                    width: 16px;
                    height: 100%;
                    text-align: center;

                    &:after {
                        width: 13px;
                        height: 5px;
                        display: inline-block;
                        content: ' ';
                        border: 1px solid transparent;
                        border-left-color: @item-selected-color;
                        border-bottom-color: @item-selected-color;
                        transform: rotate(-52deg);
                        vertical-align: 4px;
                    }
                }
            }
        }

        .tinyselect-group {
            display: block;
            padding: 1px 5px;
            background-color: @group-bg;
            border-bottom: 1px solid @group-bd;
            border-left: 3px double @group-bd;
            clear: both;
        }

        &-layout-grid {
            .tinyselect-group {
                border-top: 1px solid @group-bd;
            }

            .tinyselect-item {
                float: left;

                &-selected {
                    border: solid 1px @grid-bd;
                }
            }
        }

        &-layout-table {
            overflow-y: auto;
            overflow-x: hidden;

            .tinyselect-scroll-proxy {
                width: 100%;

                .tinyselect-group-content {
                    display: table;
                    width: 100%;
                    border-collapse: collapse;

                    .tinyselect-item {
                        display: table-row;
                        float: none;
                        border: none;

                        &-table-col {
                            padding: 2px 5px;
                            float: none;
                            display: table-cell;
                            border: 1px solid @table-bd;
                            -ms-word-break: break-all;
                            word-break: break-all;
                            -ms-word-wrap: break-word;
                            word-wrap: break-word;
                            .border-box();

                            &:first-child {
                                border-left-width: 1px;
                            }

                            &:last-child {
                                border-right-width: 1px;
                            }
                        }

                        &.tinyselect-item-hover > .tinyselect-item-table-col {
                            background-color: @table-hover-bg;
                        }
                    }
                }
            }
        }
    }

    .tinyselect-header {
        border-bottom: 1px solid @header-bd;

        .tinyselect-filter {
            border: none;
            width: 100%;
            height: 28px;
            padding: 0 2px;
            .border-box();
        }
    }

    .tinyselect-footer {
        font-size: smaller;
        padding: 2px 5px;
        border-top: 1px solid @footer-bd;
        color: @footer-color;

        &:after {
            content: ' ';
            clear: both;
            display: block;
        }

        &-left {
            display: block;
            float: left;
        }

        &-right {
            display: block;
            float: right;
        }
    }

    &-empty {
        .tinyselect-footer,
        .tinyselect-header {
            display: none !important;
        }

        .tinyselect-box {
            color: @empty-color;
        }
    }
}

.tinyselect-context {
    position: relative;
    outline: none;
    .border-box();

    &-placeholder {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        right: 0;
        line-height: inherit;
        font: inherit;
        color: #999;
        padding: 0 3px;
    }

    &-result {
        height: inherit;
        overflow-y: auto;
        line-height: inherit;
        padding: 0 3px;
        .border-box();
        .tinyselect-result-item {
            display: block;
            .text-ellipsis();
            max-width: 160px;
            min-width: 100px;
            text-align: center;
            margin: 2px 5px;
            background-color: @result-bg;
            color: @result-color;
            float: left;
            height: 24px;
            line-height: 24px;
            &-text {
                display: block;
                max-width: 120px;
                min-width: 60px;
                .text-ellipsis();
                padding: 0 5px;
                float: left;
                height: 24px;
                line-height: 24px;
            }
            &-link {
                display: block;
                width: 24px;
                text-align: center;
                cursor: pointer;
                float: right;
                height: 24px;
                line-height: 23px;

                &:after {
                    content: ' ';
                    border-top: 2px solid @result-close-color;
                    display: inline-block;
                    vertical-align: 4px;
                    width: 16px;
                }
            }
        }
    }
    &-with-arrow {
        .tinyselect-context-result {
            padding-right: 36px;
        }
        .tinyselect-context-arrow {
            position: absolute;
            right: 0;
            top: 0;
            width: 36px;
            height: 100%;
            line-height: inherit;
            text-align: center;

            &:before {
                content: ' ';
                border: 6px solid transparent;
                border-top-color: @result-arrow-color;
                display: inline-block;
                width: 12px;
                height: 12px;
                vertical-align: -3px;
                .transition(618ms, border-color);
                .border-box();
            }
        }
    }
    &.tinyselect-context-readonly {
        .tinyselect-result-item-link {
            background-color: @result-close-readonly-bg;
            cursor: initial;
        }
    }
    &:not(.tinyselect-context-readonly) {
        .tinyselect-result-item-link {
            background-color: @result-close-bg;
            cursor: pointer;
            &:hover {
                background-color: @result-close-hover-bg;
            }
        }
        .tinyselect-context-arrow {
            &:hover {
                &:before {
                    border-top-color: @result-arrow-hover-color;
                }
            }
        }
    }
}

.tinyselect-mask {
    display: none;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border: none;
    background-color: @mask-bg;
    z-index: 98;
    padding: 10px;
    .border-box();
}
